package com.zm.scsimple.circuit.breaker.client;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.util.Map;

/**
 * @author zoum
 * @create 2019/2/22 15:21
 */
@Component
public class ProfileService {

    @Autowired
    private RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "defaultProfile")
    public String profile() throws Exception{
        return restTemplate.getForObject("http://localhost:8889/profile", String.class);
    }

    public String defaultProfile() {
        return "default";
    }
}
